From 1cac1a54fd4ffbd7cc4e0de2d3f146bbeaa2e82a Mon Sep 17 00:00:00 2001 From: robertl Date: Tue, 29 Aug 2006 16:11:04 +0000 Subject: [PATCH] Don't use C99 for hex char encoding. Magproto: Issue error on open if we know it's a serial port instead of crashing later. --- gpsbabel/magproto.c | 6 +++++- gpsbabel/nmea.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gpsbabel/magproto.c b/gpsbabel/magproto.c index 25bf50a7f..2efffa97e 100644 --- a/gpsbabel/magproto.c +++ b/gpsbabel/magproto.c @@ -535,6 +535,9 @@ static int terminit(const char *portname, int create_ok) { } } is_file = 0; + if (serial_handle == NULL) { + fatal(MYNAME ": Could not open serial port %s\n", portname); + } return 1; } else { /* Does this check for an error? */ @@ -552,7 +555,8 @@ static char *termread(char *ibuf, int size) if (is_file) { return fgets(ibuf, size, magfile_h); } else { - int rc = gbser_read_line(serial_handle, ibuf, size, 2000, '\x0a', '\x0d'); + int rc; + rc = gbser_read_line(serial_handle, ibuf, size, 2000, 0x0a, 0x0d); if (rc != gbser_OK) { fatal(MYNAME ": Read error\n"); } diff --git a/gpsbabel/nmea.c b/gpsbabel/nmea.c index d29f4a908..b5612aae6 100644 --- a/gpsbabel/nmea.c +++ b/gpsbabel/nmea.c @@ -839,7 +839,7 @@ nmea_rd_posn(void) for (i = 0; i < 10; i++) { int rv; ibuf[0] = 0; - rv = gbser_read_line(gbser_handle, ibuf, sizeof(ibuf), 2000, '\x0a', '\x0d'); + rv = gbser_read_line(gbser_handle, ibuf, sizeof(ibuf), 2000, 0x0a, 0x0d); if (global_opts.debug_level > 1) { warning( "READ: %s\n", ibuf); } -- 2.30.2